package com.yan.design.two.behavior.s5.g1;


import java.util.Observable;
import java.util.Observer;

/**
 * 5. 观察者模式
 *     观察者类1号
 * @author shengren.yan
 * @create 2022-08-10
 */
public class Subject3 implements Observer{

    private String state = "eating";
    private String name;

    public Subject3(String name){
        this.name = name;
    }

    public void update(Observable o, Object arg) {
        Subject sub = (Subject) o;
        System.out.println(sub.getName()+" 参数 "+arg+" "+ this.getName()+" running3.....");
        setState("running");
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
